import React, { Component } from 'react'
import './index.css'

export default class Footer extends Component {
    // 调用清除所有已完成的函数
    clearAllHaveDone = () => {
        this.props.removeHaveDone()
    }

    // 设置所有任务的状态
    setAllHaveDone = () => {
        this.props.setAllHaveDone()
    }

    render() {
        const {finishedTasks, disabled, allTasks, allFlag} = this.props
        return (
            <div className="footerBox">
                <input key={finishedTasks} disabled={disabled} type="checkbox" onChange={this.setAllHaveDone} defaultChecked={allFlag} name="全选" id="checkBox"/>
                <span id="finish">已完成 {finishedTasks}</span>/
                <span id="all">全部 {allTasks}</span>
                <button className="btnPlus" onClick={this.clearAllHaveDone}>清除完成</button>
            </div>
        )
    }
}
